﻿package mortal.game.view.copy.sunbathCopy.view
{
    import com.gengine.global.*;
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.sunbathCopy.*;
    import mortal.game.view.copy.sunbathCopy.render.*;
    import mortal.mvc.core.*;

    public class SunbathCopySkillBarNew extends View
    {
        protected var _bg:GBitmap;
        protected var _btnArr:CellsGridSprite;
        private static var _instance:SunbathCopySkillBarNew;

        public function SunbathCopySkillBarNew()
        {
            this.layer = LayerManager.uiLayer;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            LoaderHelp.addResCallBack(ResFileConst.sunbathCopy, this.onResCompl);
            return;
        }// end function

        private function onResCompl() : void
        {
            this._bg = UIFactory.gBitmap(ImagesConst.SunbathCopySkillBarBg, 2, 33, this);
            this._btnArr = UIFactory.getUICompoment(CellsGridSprite);
            this._btnArr.colNum = 5;
            this._btnArr.vCellWid = 96;
            this._btnArr.hCellWid = 100;
            this._btnArr.genCellFun = UIFactory.getUICompoment;
            this._btnArr.genCells(4, SunbathOprBtn);
            this._btnArr.x = 9;
            this._btnArr.y = 0;
            this.addChild(this._btnArr);
            this.initBtn();
            this.updateNum();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg = null;
            this._btnArr = null;
            return;
        }// end function

        public function updateNum() : void
        {
            var _loc_1:* = SunbathUtil.getSkillInfoArr();
            if (this._btnArr != null)
            {
                this._btnArr.updateAllNotDispose(_loc_1, SunbathOprBtn, "updateNum");
            }
            return;
        }// end function

        private function initBtn() : void
        {
            var _loc_3:Object = null;
            var _loc_4:SunbathOprBtn = null;
            var _loc_1:* = SunbathUtil.getSkillInfoArr();
            var _loc_2:int = 0;
            while (_loc_2 < this._btnArr.cellArr.length)
            {
                
                _loc_3 = _loc_1[_loc_2];
                _loc_4 = this._btnArr.cellArr[_loc_2];
                _loc_4.updateInof(_loc_3);
                _loc_2++;
            }
            return;
        }// end function

        override public function stageResize() : void
        {
            super.stageResize();
            x = Global.stage.stageWidth - 425;
            y = Global.stage.stageHeight - 200;
            return;
        }// end function

        public static function get instance() : SunbathCopySkillBarNew
        {
            if (_instance == null)
            {
                _instance = new SunbathCopySkillBarNew;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
